/**
 * Created by enixjin on 1/10/18.
 */
import "rxjs/add/operator/mergeMap";
import {User} from "../../../../entity/User";
import {UserService} from "../../../../service/userService";
import {AbstractUserRESTAction} from "../AbstractUserRESTAction";

export class UserDeleteRESTAction extends AbstractUserRESTAction {
    constructor(private payload: User,
                private userService: UserService,
                private _localKey: string) {
        super(_localKey);
        // clone to avoid reference conflict
        // this.payload = Object.assign({}, user);
    }

    send() {
        return this.userService.delete(this.payload.id);
    }

    updateLocal(local, _payload): void {
        // local.set(this._localKey, local.get(this._localKey).filter(u => u.id !== _payload.id));
    }
}
